#ifndef TITLEBAR_H
#define TITLEBAR_H

#include <QWidget>
#include <QLabel>
#include <QPushButton>

class TitleBar : public QWidget
{
    Q_OBJECT
public:
    explicit TitleBar(QWidget *parent = nullptr);
    void initGUI();

signals:
    void signalClose();

private slots:
    void OnClocked();
    void mouseDoubleClickEvent(QMouseEvent *event) override;
    void paintEvent(QPaintEvent *event) override;

// 鼠标按住窗口移动
#if defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID)
// Linux环境
    void mouseMoveEvent(QMouseEvent *event) override;
    void mousePressEvent(QMouseEvent *event) override;

#endif
#if defined (Q_OS_WINDOWS)
// Windows环境
    void mousePressEvent(QMouseEvent *event) override;
#endif


private:

#if defined (Q_OS_LINUX) && !defined (Q_OS_ANDROID)
    // Linux环境
    // 窗口移动所需的变量
    QPoint winpos;
    QPoint mousepos;
    QPoint diffpos;
#endif

    QLabel *logo;
    QLabel *title;

    QPushButton *setbtn;
    QPushButton *minbtn;
    QPushButton *maxbtn;
    QPushButton *closebtn;
};

#endif // TITLEBAR_H
